<template>
	<view :class="['search', focus&&'focus']">
		<input 
		@focus="focus = true" 
		@blur="focus = false" 
		@confirm="search" 
		:placeholder="placeholder" 
		:value="value"
		@input="input" 
		type="text" 
		class="search-input">
	</view>
</template>

<script>
	export default {
		name: 'search-input',
		props: {
			value: '',
			placeholder: {
				type: String,
				default: '请输入内容'
			}
		},
		data() {
			return {
				focus: false
			}
		},
		methods: {
			clear() {
				this.$emit('clear')
			},
			search() {
				this.$emit('search')
			},
			input(e) {
				this.$emit('input', e.target.value)
			}
		}
	}
</script>

<style scoped lang="less">
	.search {
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		background-color: #fff;
		border-radius: 6rpx;
		transition: all .3s;
		height: 75rpx;
		// border: 1rpx solid #B8B8B8;
		box-sizing: border-box;
		&.focus {
			transition: all .3s;
			box-shadow: 0 6rpx 16rpx -8rpx #ffffff14, 0 9rpx 28rpx #ffffff0d, 0 12rpx 48rpx 16rpx #ffffff08;
			background-color: #fff;
		}

		image {
			width: 36rpx;
			height: 36rpx;
		}

		input {
			margin-left: 20rpx;
			font-size: 28rpx;
			flex: 1;
		}
	}
</style>
